home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Technology Demos and Tools.iso / showmetv / utilities / bin / showmeab
Encoding:
Text File  |  1996-02-27  |  4.1 KB  |  231 lines

  1. #!/bin/sh
  2. #
  3. # Address Book startup script.
  4. #
  5. # @(#)showmeab.sh    1.6 96/02/26 Copyright 1993-94 Sun Microsystems, Inc.  All Rights Reserved.
  6. #
  7.  
  8.  
  9. #
  10. # Where various components of this application live.
  11. #
  12. ShowMeHome=
  13. showmeHome=
  14. utilsHome=
  15. helpHome=
  16. motifHome=
  17.  
  18. helpExecDir=
  19. showmeExecDir=
  20. machDepExecDir=
  21.  
  22. osVersion=
  23.  
  24.  
  25. programName=$0
  26.  
  27.  
  28. #
  29. # If a path name is a symbolic link, resolve it.
  30. #
  31. GetRealPath()
  32. {
  33.     pathName="$1"
  34.     level=1
  35.  
  36.  
  37.     while [ -h "$pathName" ] ; do
  38.  
  39.         level=`/bin/expr $level + 1`
  40.         if [ $level -gt 10 ] ; then
  41.             echo "$pathName: too many levels of symbolic links"
  42.             break;
  43.         fi
  44.  
  45.         #
  46.         # First, make sure we have an absolute path name.
  47.         #
  48.         if IsRelativePath "$pathName" ; then
  49.             pathName=`/bin/pwd`/"$pathName"
  50.         fi
  51.  
  52.         #
  53.         # Then determine where the link points (via "ls -l")
  54.         #
  55.         dirName=`/bin/dirname $pathName`
  56.         link=`/bin/ls -l $pathName | sed -e 's,.* -> ,,g'`
  57.  
  58.         if IsRelativePath "$link" ; then
  59.             pathName="$dirName"/"$link"
  60.         else
  61.             pathName="$link"
  62.         fi
  63.     done
  64.  
  65.     echo "$pathName"
  66.  
  67.     return 0
  68. }
  69.  
  70.  
  71. #
  72. # Is this a relative path name (i.e., doesn't begin with "/")?
  73. #
  74. IsRelativePath()
  75. {
  76.     pathName="$1"
  77.  
  78.     if [ `echo "$pathName" | sed -e 's,^/.*,absolute,g'` = "absolute" ] ; then
  79.         return 1
  80.     else
  81.         return 0
  82.     fi
  83. }
  84.  
  85.  
  86. #
  87. # Determine what version of Solaris we're running
  88. #
  89. GetOSVersion()
  90. {
  91.            OS=`/bin/uname -r`
  92.  
  93.     case $OS in
  94.     4.*)    osVersion=SUNOS;;
  95.     5.*)    case `/bin/uname -p` in 
  96.         sparc)
  97.             osVersion=SVR4;;
  98.         *86)
  99.             osVersion=I386;;
  100.         esac;;
  101.     A.*)
  102.         osVersion=HPUX;;
  103.     esac
  104.  
  105. }
  106.  
  107.  
  108. #
  109. # Determine where ShowTV lives.
  110. # We assume that it's two levels up above the directory containing
  111. # this script.
  112. #
  113. GetPaths()
  114. {
  115.     tmpDir=`GetRealPath $programName`
  116.     tmpDir=`dirname $tmpDir`
  117.     ShowMeHome=`( cd $tmpDir/../.. && /bin/pwd )`
  118.  
  119.     showmeHome=$ShowMeHome/ShowMeTV
  120.     utilsHome=$ShowMeHome/utilities
  121.     helpHome=$ShowMeHome/help
  122.     motifHome=$ShowMeHome/motif
  123. }
  124.  
  125.  
  126. #
  127. # Set up ShowTV environment.
  128. #
  129. SetupEnvironment()
  130. {
  131.     helpExecDir=$helpHome/bin
  132.     HHPATH=$utilsHome/share ; export HHPATH
  133.  
  134.     showmeExecDir=$showmeHome/bin
  135.     machDepExecDir=$showmeExecDir/bin-$osVersion
  136.     utilsExecDir=$utilsHome/bin/bin-$osVersion
  137.     sunsolBinDir=`dirname $0`
  138.  
  139.  
  140.     #
  141.     # Add ShowTV and HyperHelp executable directories to shell search path
  142.     #
  143.     PATH=${showmeExecDir}:${machDepExecDir}:${utilsExecDir}:${helpExecDir}:${sunsolBinDir}:${PATH}
  144.  
  145.     export PATH
  146.  
  147.     #
  148.     # Use our own Motif key_bindings because the built-in ones
  149.     # in the Motif library don't handle all the Sun keys correctly.
  150.     # However, if XMBINDDIR is already set, leave it alone!
  151.     #
  152.  
  153.     if [ -d ${motifHome}/share/key_bindings ]; then
  154.         XMBINDDIR=${XMBINDDIR:=${motifHome}/share/key_bindings}
  155.         export XMBINDDIR
  156.     fi
  157. }
  158.  
  159.  
  160. #
  161. # Update loader search path as necessary.
  162. #
  163. SetLibraryPath()
  164. {
  165.     motifLibDir=$motifHome/lib-$osVersion
  166.  
  167.     [ -d $motifLibDir ] || {
  168.         echo "Sorry, can't run ShowTV - the Motif shared library is missing."
  169.         exit 1
  170.     }
  171.  
  172.     #
  173.     # Setup Motif environment variables for SUNOS
  174.     #
  175.     if [ $osVersion = "SUNOS" ] ; then
  176.         XLIBDIR=$motifLibDir
  177.         export XLIBDIR
  178.         XLIBI18N_PATH=$motifLibDir/X11
  179.         export XLIBI18N_PATH
  180.         XKEYSYMDB=$motifLibDir/X11/XKeysymDB
  181.         export XKEYSYMDB
  182.     fi
  183.  
  184.     # On 4.x systems, we are required to set LD_LIBRARY_PATH
  185.     # On 5.2 and 5.3 systems, we must set it to pick up the patched libXt
  186.  
  187.     #
  188.     # Prepend the ShowTV specific X and Motif library directory,
  189.     # followed by the regular Sun OpenWindow library directory.
  190.     #
  191.     openwinHome=${OPENWINHOME:-/usr/openwin}
  192.  
  193.     case $OS in
  194.         4.*)
  195.         LD_LIBRARY_PATH=${motifLibDir}:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  196.         5.[23])
  197.         LD_LIBRARY_PATH=${motifLibDir}:${motifLibDir}/patched-libs,5.2:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  198.         *)
  199.         LD_LIBRARY_PATH=${motifLibDir}:${openwinHome}/lib:${LD_LIBRARY_PATH};;
  200.     esac
  201.  
  202.     export LD_LIBRARY_PATH
  203. }
  204.  
  205.  
  206. ####################################################
  207.  
  208. GetOSVersion
  209.  
  210. GetPaths
  211.  
  212. SetupEnvironment
  213.  
  214. # We now use /usr/dt/lib for motif library. Don't need to set up environment
  215. # to look for stuff in /opt/SUNWsunsol/motif
  216. # SetLibraryPath
  217.  
  218. #
  219. # Cleanup Motif key bindings
  220. #
  221. #
  222. #if [ -x ${motifHome}/lib-${osVersion}/bin/delbind_util ]; then
  223. #    ${motifHome}/lib-${osVersion}/bin/delbind_util $*
  224. #fi
  225.  
  226.  
  227. echo "Starting Address Book"
  228. exec $utilsExecDir/`basename $0` $@
  229.  
  230. exit 0
  231.